import request from '@/utils/request'
import type {BaseResponse} from "@/utils/request";
import { genTestUserSig } from "@/pages/TUIKit/debug";
export interface AccountImportBody{
  UserID: string
  Nick: string
  FaceUrl: string
}
export interface AccountImportRes{
  ActionStatus: string
  ErrorInfo: string
  ErrorCode: number
}
const config = {
  userID: "administrator", //User ID
  SDKAppID: 1400792703, // Your SDKAppID
  secretKey: 'c04e8a9412dd7cff393e5341e51331a79f822abcbc7bb64eb891e65d14740b5f', // Your secretKey
};
const userSig = genTestUserSig(config).userSig
export const postAccountImportRes = (formData:AccountImportBody): Promise<AccountImportRes> => {
  console.log('usersig', userSig)
  return new Promise((resolve, reject) => {
    uni.request({
      url: `https://console.tim.qq.com/v4/im_open_login_svc/account_import?sdkappid=${config.SDKAppID}&identifier=${config.userID}&usersig=${userSig}&random=${Math.round(Math.random() * 10000000)}&contenttype=json`,
      method: 'POST',
      data: formData,
      success(res){
        resolve(res.data as AccountImportRes)
      },
      fail(res){
        reject(res)
      }
    })
  })
}